/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * Created on Feb 19, 2007
 */
package cesynch.crystal.synchronizer;


/**
 * <p>Class represents a group name and it's group members.</p>
 * 
 * @author <a href="mailto:cesynch@gmail.com">cesynch</a>
 * 
 */
public class Group
{
    /** The group name */
    private String nm;
    
    private int ceSI_ID = -1;
    /**
     * <p>Default no argument constructor.</p>
     */
    public Group()
    {
        super();
    }

    /**
     * <p>Contructor taking the group name as an arguement.</p>
     * 
     * @param name the group's name.
     */
    public Group(String name)
    {
        setName(name);
    }
    
    /**
     * <p>Returns the group's name.</p>
     * 
     * @return Returns the name of the group.
     */
    public String getName()
    {
        return nm;
    }
    
    /**
     * <p>Sets the group's name.</p>
     * 
     * @param name The name of the group to set.
     */
    public void setName(String name)
    {
        nm = name;
    }
    

    
    /**
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj)
    {
        if (obj == null)
        {
            return false;
        }
        else if (!(obj instanceof Group))
        {
            return false;
        }
        Group comp = (Group) obj;
        if (comp.getName() != null)
        {
            return comp.getName().equalsIgnoreCase(getName());
        }
        else if (getName() == null) // compare to's group is null / so is this one's
        {
            return true;
        }
        return false;
    }
    
    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode()
    {
        if (getName() == null)
        {
            return 27;
        }
        return getName().toLowerCase().hashCode();
    }
    
    /**
     * @see java.lang.Object#toString()
     */
    public String toString()
    {
        return "Group: " + getName();
    }

    /** 
     * Returns the group's InfoObject SI_ID.
     * 
     * @return the group's InfoObject SI_ID
     */
    public Integer getCeSI_ID()
    {
        return new Integer(ceSI_ID);
    }
    
    /**
     * Sets the group's InfoObject SI_ID
     * 
     * @param ceSI_ID the group's InfoObject SI_ID
     */
    public void setCeSI_ID(int ceSI_ID)
    {
        this.ceSI_ID = ceSI_ID;
    }
}
